package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

@Getter
@Setter
@ToString
public class Tour {
    private Long id;
    //关联的景点
    private Long ticketId;
    //游玩的时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date playTime;
    //填写的游客的名字
    private String name;

    private String phone;
    //真实的金额
    private BigDecimal realDel;
    //状态:初始为1,未付款,付款之后变成2
    private Integer state;

    //关联,这是哪一个用户的订单
    private Long userId;
    //关联
    private ScenicTicket ticket;

    //获取到票面信息
    public String getTicketName() {
        if (ticket.getName() != null) {
            return ticket.getName();
        }
        return "";
    }

    //在前端拼接太难了,在后台将跳转的值拼接出来给他
    public String getUrl() {
        String url = "";
        if (ticketId != null && id != null) {

            url = ticketId + "&dealId=" + id;
        }
        return url;
    }

    public String getStateDisplay() {
        if (state != null) {
            if (state == 1) {
                return "还未付款";
            } else {
                return "已付款";
            }
        }

        return "";
    }


}